package com.lhf.sparecost.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.lhf.error.ErrorMessageVo;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author 尐痞猫
 * @date2021-06-26 0:21
 */
@Data
public class SpareCostAddVo {
    @NotBlank(message=ErrorMessageVo.GONGCHANGBIANMABUNENGWEIKONG)
    private String   legalPlantCode;
    @NotBlank(message=ErrorMessageVo.BEIJIANBIANMABUNENGWEIKONG)
    private String   spareClassCode;
    @NotNull(message=ErrorMessageVo.HANSHUILEIXINGBIANMABUNENGWEIKONG)
    private Integer   taxTypeCode;
    @NotNull(message=ErrorMessageVo.JIAGELEIXINGBIANMABUNENGWEIKONG)
    private Integer   priceTypeCode;
    @NotNull(message=ErrorMessageVo.BIBIEBUNENGWEIKONG)
    private Integer   currencyCode;
    @NotNull(message=ErrorMessageVo.KSISHISHIJIANBUNENGWEIKONG)
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date     startTime;
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date     endTime;
    @NotNull(message=ErrorMessageVo.CHENGBENJIABUNENGWEIKONG)
    private Double   sparePrice;
    private String remark;
    private Integer statusCode;

    public Integer getStatusCode(Date startTime,Date endTime){
        Date now = new Date();
       //只有在开始时间小于当前时间，结束时间大于当前时间，才启用
        if(startTime.getTime()<=now.getTime()&&endTime.getTime()>=now.getTime()){
            return 1;
        }
        return 0;
    }
}
